﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BaHuan.BusinessLayer;
using BaHuan.Common;
using BaHuan.Entities;

namespace BaHuan
{
    public partial class FrmKiemTraPhieuNhapKho : Form
    {
        private BangKeNhapHangMgt bangkenhaphangMgt = new BangKeNhapHangMgt();
        private CTBangKeNhapHangMgt ctbangkenhaphangMgt = new CTBangKeNhapHangMgt();

        private BangKeNhapHang bangkenhaphang;
        public BangKeNhapHang BangKeNhapHang
        {
            set { this.bangkenhaphang = value; }
            get { return this.bangkenhaphang; }
        }
        public FrmKiemTraPhieuNhapKho()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FrmKiemTraPhieuNhapKho_Load(object sender, EventArgs e)
        {
            dgvNhaphang.AutoGenerateColumns = false;
            groupBox1.Enabled = false;
            txtManhaPhieu.Text = bangkenhaphang.MaSo;
            txtDiaChi.Text = bangkenhaphang.DiaChi;
            txtNguoiLap.Text = bangkenhaphang.NguoiLap;
            txtNhanVienGiaoHang.Text = bangkenhaphang.NguoiGiaoHang;
            txtKeToanTruong.Text = bangkenhaphang.KeToanTruong;
            cboNhaCungCap.SelectedText = bangkenhaphang.NhaCungCap;
            dtpNgayNhapHang.Value = bangkenhaphang.NgayThang;

            BindingToGrid();

        }
        public void BindingToGrid()
        {
            ResultObj result = new ResultObj();

            result = ctbangkenhaphangMgt.GetAllCTBangKeNhapHang();

            List<CTBangKeNhapHang> lstCTBangKeNhapHang = (from c in (List<CTBangKeNhapHang>)result.Result
                                                          where c.IdBangKe == this.bangkenhaphang.Id
                                                          select c).ToList();

            dgvNhaphang.DataSource = lstCTBangKeNhapHang;     

        }

        private void cboNhaCungCap_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.cboNhaCungCap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
        }
    }
}
